{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2023-11-21T07:08:07.230573700Z",
     "start_time": "2023-11-21T07:08:07.126521300Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import re\n",
    "\n",
    "df = pd.read_csv('../static/data/job_info.csv')\n",
    "\n",
    "df['职位名称'] = df['职位名称'].apply(lambda x: x.split('_')[1] if len(x.split('_')) == 2 else x)\n",
    "df['职位名称'] = df['职位名称'].apply(lambda x: x.split('(')[0])\n",
    "df['职位名称'] = df['职位名称'].apply(lambda x: x.split('-')[1] if len(x.split('-')) == 2 else x)\n",
    "df['职位类型'] = df['职位类型'].apply(lambda x: '无' if pd.isnull(x) else x)\n",
    "df['学历条件'] = df['服务条件'].apply(lambda x: re.match('-.*?(本科|硕士|博士).*?', x))\n",
    "df['经验条件'] = df['服务条件'].apply(lambda x: re.match('.*?([1-9]年|[1-9]-[1-9]年).*?经验', x))\n",
    "df['学历条件'] = df['学历条件'].apply(lambda x: '无' if pd.isnull(x) else x.group(1))\n",
    "df['经验条件'] = df['经验条件'].apply(lambda x: '无' if pd.isnull(x) else x.group(1))\n",
    "df['是否经验'] = df['经验条件'].apply(lambda x: '不需要经验' if x == '无' else '需要经验')\n",
    "df['发布时间'] = df['发布时间'].apply(lambda x: x.split('-')[0]+'-'+x.split('-')[1])\n",
    "df = df[['职位名称', '职位类型', '发布时间', '更新时间', '招聘人数', '服务条件', '工作内容', '工作地点', '是否热门',\n",
    "         '学历条件', '经验条件','是否经验']]\n",
    "df.to_csv('../static/data/pre_job_info.csv', encoding='utf_8_sig', index=None)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
